﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrightIdeasSoftware;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace Managistics.Warehouse.Views.Controls
{
    public class GradientRenderer : BaseRenderer
    {
        public override bool OptionalRender(Graphics g, Rectangle r)
        {
            if (this.ListView.View != View.Tile)
                return false;

            using (LinearGradientBrush gradient = new LinearGradientBrush(r, Color.Gold, Color.Fuchsia, 0.0))
            {
                g.FillRectangle(gradient, r);
            }
            g.DrawRectangle(Pens.Black, r);

            StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap);
            fmt.LineAlignment = StringAlignment.Center;
            fmt.Trimming = StringTrimming.EllipsisCharacter;
            fmt.Alignment = StringAlignment.Near;
            g.DrawString(this.GetText(), this.Font, this.TextBrush, r, fmt);

            return true;
        }
    }
}
